home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
cgazv5n5.arc
/
LIST10.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-23
|
868b
|
35 lines
/*---------------------------------------- Listing 10 -----
* Demonstration of longjmp() and setjmp()
* See Listing 1 for copyright terms.
*-------------------------------------------------------*/
#include <stdio.h>
#include <setjmp.h>
void main ( void );
void main()
{
jmp_buf PgmState;
int JmpStatus;
JmpStatus = setjmp ( PgmState );
if ( JmpStatus == 0 )
{
printf
( "I just happen to be here since I fell into it\n" );
printf ( "But now, I'll mix things up a little!\n" );
longjmp ( PgmState, 25 );
}
else
{
printf
("I've been thrown here with value %d\n", JmpStatus );
if ( JmpStatus < 0 )
return;
}
printf ( "That was fun\n" );
printf ( "Let's do this one last time\n" );
longjmp ( PgmState, -1 );
}